
import request from '@/utils/request'

// 查询领导审批表单列表
export function listTemplate(query) {
  return request({
    url: '/supply/template/list',
    method: 'get',
    params: query
  })
}

// 查询领导审批表单详细
export function getTemplate(id) {
  return request({
    url: '/supply/template/' + id,
    method: 'get'
  })
}

// 新增领导审批表单
export function addTemplate(data) {
  return request({
    url: '/supply/template',
    method: 'post',
    data: data
  })
}

// 修改领导审批表单
export function updateTemplate(data) {
  return request({
    url: '/supply/template',
    method: 'put',
    data: data
  })
}

//更新签名
export function updateSign(orderId, sign) {
  return request({
    url: "/supply/template/updateSign?orderId=" + orderId + "&sign=" + sign,
    method: "put",
  })
}


// 删除领导审批表单
export function delTemplate(id) {
  return request({
    url: '/supply/template/' + id,
    method: 'delete'
  })
}

//根据订单id更新签名
export function updateFlowTemplateSign(orderId, signature) {
  return request({
    url: `/supply/template/updateSign?orderId=${orderId}&sign=${signature}`,
    method: 'put',
    data: data
  })
}

// 删除审批流程模板
export function delFlowTemplate(id) {
  return request({
    url: '/supply/template/' + id,
    method: 'delete'
  })
}

// 预览审批流程模板
export function previewFlowTemplate(data) {
  return request({
    url: '/supply/template/preview',
    method: 'post',
    data: data
  })
}

// 获取所有可用审批人员列表
export function getApproverList() {
  return request({
    url: '/system/user/list',
    method: 'get'
  })
}

// 生成审批流程模板代码
export function genFlowTemplateCode(tableName) {
  return request({
    url: '/supply/template/genCode/' + tableName,
    method: 'get'
  })
}

// 同步审批流程模板字段
export function synchFlowTemplateField(tableName) {
  return request({
    url: '/supply/template/synchField/' + tableName,
    method: 'get'
  })
}
